package object

import (
	"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/schedulerhints"
	"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
)

type Template struct {
	HeatTemplateVersion string                      `json:"heat_template_version"`
	Description         string                      `json:"description,omitempty"`
	Resources           map[string]TemplateResource `json:"resources"`
}

type TemplateResource struct {
	Type       string      `json:"type"`
	Properties interface{} `json:"properties"`
}

type GetResource struct {
	GetResource string `json:"get_resource"`
}

type Server struct {
	Name                 string                         `json:"name"`
	KeyName              string                         `json:"key_name,omitempty"`
	Flavor               interface{}                    `json:"flavor"`
	UserData             string                         `json:"user_data,omitempty"`
	BlockDeviceMappingV2 *[]BlockDeviceMappingV2        `json:"block_device_mapping_v2"`
	Networks             *[]ServerNetwork               `json:"networks"`
	Metadata             *ServerMetadata                `json:"metadata"`
	SchedulerHints       *schedulerhints.SchedulerHints `json:"scheduler_hints,omitempty"`
	SecurityGroups       []string                       `json:"security_groups,omitempty"`
	Host                 string                         `json:"host,omitempty"`
	Image                string                         `json:"image,omitempty"`
}

type Flavor struct {
	Name     string `json:"name"`
	FlavorID string `json:"flavorid"`
	Vcpus    string `json:"vcpus"`
	Ram      string `json:"ram"`
	IsPublic *bool  `json:"is_public"`
	Disk     string `json:"disk"`
}

type Container struct {
	Name           string           `json:"name"`
	Cpu            int              `json:"cpu"`
	Hints          string           `json:"hints,omitempty"`
	Image          string           `json:"image"`
	ImageDriver    string           `json:"image_driver"`
	Interactive    string           `json:"interactive"`
	Memory         int              `json:"memory"`
	Networks       *[]ServerNetwork `json:"networks"`
	RestartPolicy  string           `json:"restart_policy"`
	SecurityGroups []interface{}    `json:"security_groups,omitempty"`
	Tty            string           `json:"tty"`
}

type BlockDeviceMappingV2 struct {
	Image               string      `json:"image,omitempty"`
	VolumeSize          int         `json:"volume_size"`
	VolumeID            interface{} `json:"volume_id,omitempty"`
	Blank               string      `json:"blank,omitempty"`
	BootIndex           int         `json:"boot_index"`
	DeleteOnTermination string      `json:"delete_on_termination,omitempty"`
	DiskBus             string      `json:"disk_bus,omitempty"`
}

type ServerNetwork struct {
	Port GetResource `json:"port,omitempty"`
}

type ContainerNetwork struct {
	Port interface{} `json:"port"`
}

type FloatingIP struct {
	FloatingNetworkID string      `json:"floating_network_id,omitempty"`
	FloatingIPAddress string      `json:"floating_ip_address,omitempty"`
	PortID            GetResource `json:"port_id,omitempty"`
}

type Network struct {
	Name      string `json:"name"`
	QosPolicy string `json:"qos_policy,omitempty"`
	Shared    bool   `json:"shared,omitempty"`
}

type NetworkGateway struct {
	Connections []NetworkGatewayConn   `json:"connections"`
	Devices     []NetworkGatewayDevice `json:"devices"`
}

type NetworkGatewayConn struct {
	InterfaceName string `json:"interface_name"`
}

type NetworkGatewayDevice struct {
	Network          string `json:"network"`
	SegmentationID   string `json:"segmentation_id"`
	SegmentationType string `json:"segmentation_type"`
}

type Subnet struct {
	Name           string              `json:"name"`
	EnableDhcp     string              `json:"enable_dhcp,omitempty"`
	GatewayIP      string              `json:"gateway_ip,omitempty"`
	HostRoutes     []subnets.HostRoute `json:"host_routes,omitempty"`
	Network        GetResource         `json:"network"`
	DnsNameservers []string            `json:"dns_nameservers"`
	Cidr           string              `json:"cidr"`
}

type SubnetHostRoute struct {
	Destination string `json:"destination"`
	Nexthop     string `json:"nexthop"`
}

type Router struct {
	Name                string              `json:"name,omitempty"`
	ExternalGatewayInfo ExternalGatewayInfo `json:"external_gateway_info"`
}

type ExternalGatewayInfo struct {
	Network    string `json:"network,omitempty"`
	EnableSNAT string `json:"enable_snat,omitempty"`
}

type RouterInterface struct {
	Port   *GetResource `json:"port,omitempty"`
	Router *GetResource `json:"router,omitempty"`
	Subnet *GetResource `json:"subnet,omitempty"`
}

type RouterExtraRoute struct {
	Destination string `json:"destination"`
	Nexthop     string `json:"nexthop"`
	RouterID    string `json:"router_id"`
}

type Port struct {
	Name      string        `json:"name,omitempty"`
	FixedIPs  []FixedIPOpts `json:"fixed_ips,omitempty"`
	Network   interface{}   `json:"network,omitempty"`
	NetworkID string        `json:"network_id,omitempty"`
}

type FixedIPOpts struct {
	IPAddress       string       `json:"ip_address,omitempty"`
	IPAddressSubstr string       `json:"ip_address_substr,omitempty"`
	SubnetID        string       `json:"subnet_id,omitempty"`
	Subnet          *GetResource `json:"subnet,omitempty"`
}

type ServerMetadata struct {
	AdminPass string `json:"admin_pass,omitempty"`
}
